import { postJson, deleteJson, putJson, get } from "@/common/VueAxios"
import type { ApiResult, ApiPageResult, PageInfo } from "./basemodel"

export interface Project {
    id?: number
    createtime?: string
    git?: string
    name?: string
}
export interface ProjectSearch extends PageInfo {
    name?: string
}

export function save(dto: Project) {
    return dto.id == undefined || dto.id == 0 ? create(dto) : update(dto)
}

export function create(dto: Project) {
    return postJson<Project, ApiResult<Project>>("/project", dto)
}

export function update(dto: Project) {
    return putJson<Project, ApiResult<Project>>("/project", dto)
}

export function removeById(id: number) {
    return remove([id])
}

export function remove(ids?: number[]) {
    return deleteJson<number[] | undefined, ApiResult>("/project", ids)
}
export function details(id?: number) {
    return get<{ id?: number }, ApiResult<Project>>("/project/details", { id })
}
export function getpage(dto: ProjectSearch) {
    return get<PageInfo, ApiPageResult<Project>>("/project/getpage", dto)
}



